<?php

class Core_Action_Admin_Setting_General  extends Action_Admin
{
	function execute($request, $initial = TRUE, $script = NULL)
	{

		if ($initial)
		{
			Agilet::setVar('breadcrum', array(
				array(
					'url' => 'admin/setting',
					'label' => 'Settings'
				),
				array(
					'url' => 'admin/setting/general',
					'label' => 'General Setting'
				)
			));

		}

		$form = Form::factory('core/admin/setting/general');

		$name = 'general';

		if ($request -> isGet())
		{
			$values = (array)Agilet::getSetting($name);
			$form -> setData($values);
		}

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$value = $form -> getData();
			unset($value['buttons']);
			Agilet::setSetting($name, $value);
		}

		$request -> response = View::render('core/html/admin/edit', $data = array('form' => $form));
	}

}
